	import CryptoJS from './crypto-js.min.js'

	//加密 返回Data
	export const encryptData=function (word, keyStr, ivStr){
		keyStr = keyStr ? keyStr : "6C4E60E55552386C";
		ivStr = ivStr ? ivStr : "5315265453152654";
		let key = CryptoJS.enc.Utf8.parse(keyStr);
		let iv = CryptoJS.enc.Utf8.parse(ivStr);
		let srcs = CryptoJS.enc.Utf8.parse(word);
		
		let encrypted = CryptoJS.AES.encrypt(srcs, key, {
		iv,
		mode: CryptoJS.mode.CBC,
		padding: CryptoJS.pad.Pkcs7
		});
		return {"Body":encrypted.toString()};
		}
		
		//加密 返回加密串
		export const encrypt=function (word, keyStr, ivStr){
			keyStr = keyStr ? keyStr : "6C4E60E55552386C";
			ivStr = ivStr ? ivStr : "5315265453152654";
			let key = CryptoJS.enc.Utf8.parse(keyStr);
			let iv = CryptoJS.enc.Utf8.parse(ivStr);
			let srcs = CryptoJS.enc.Utf8.parse(word);
			
			let encrypted = CryptoJS.AES.encrypt(srcs, key, {
			iv,
			mode: CryptoJS.mode.CBC,
			padding: CryptoJS.pad.Pkcs7
			});
			return encrypted.toString();
			}
			
		
//解密
	export const decrypt=function (word, keyStr, ivStr){
		keyStr = keyStr ? keyStr : "6C4E60E55552386C";
		ivStr = ivStr ? ivStr : "5315265453152654";
		var key = CryptoJS.enc.Utf8.parse(keyStr);
		let iv = CryptoJS.enc.Utf8.parse(ivStr);
		
		var decrypt = CryptoJS.AES.decrypt(word, key, {
		iv,
		mode: CryptoJS.mode.CBC,
		padding: CryptoJS.pad.Pkcs7
		});
		return decrypt.toString(CryptoJS.enc.Utf8);
		}
		
		
		export default{
			encrypt,
			decrypt,
			encryptData
		}